package com.polaris.server.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.polaris.common.utils.RespBean;
import com.polaris.server.dto.TripQueryParam;
import com.polaris.server.pojo.TrafficTrip;
import com.polaris.server.service.ITrafficTripService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author polaris
 * @since 2021-06-02
 */
@Api(tags="客流记录管理")
@RestController
@RequestMapping("/api/traffic/trip")
public class TrafficTripController {

    private final ITrafficTripService trafficTripService;


    public TrafficTripController(ITrafficTripService trafficTripService) {
        this.trafficTripService = trafficTripService;
    }

    public RespBean trafficTripList(@RequestParam Integer page, @RequestParam Integer limit, @RequestBody TripQueryParam queryParam){
        Page<TrafficTrip> objectPage = new Page<>(page,limit);
        IPage<TrafficTrip> tripPage = trafficTripService.list(queryParam, objectPage);
        HashMap<String, Object> resultMap = new HashMap<>();
        resultMap.put("total", tripPage.getTotal());
        resultMap.put("data", tripPage.getRecords());
        return RespBean.success("查询客流数据成功",resultMap);
    }
}
